<?php

namespace Platform\Libs;

class RedisCache extends \Redis {

    //保存类实例的静态成员变量
    private static $_instance;

    //单例方法
    public static function getInstance($host, $port, $timeout, $auth = false, $dbnumber = 0) {
        if (!isset(self::$_instance)) {
            $redis = new RedisCache();
            $redis->connect($host, $port, $timeout);
            if ($auth) {
                $redis->auth($auth);
            }
            if (intval($dbnumber) != 0) {
                $redis->select($dbnumber);
            }
            self::$_instance = $redis;
        }
        return self::$_instance;
    }

    public function __construct() {
        parent::__construct();
    }

}
